//
//  ZYIndexMiddleView.m
//  YiLin
//
//  Created by Zyark on 2018/6/8.
//  Copyright © 2018年 Zyark. All rights reserved.
//

#import "ZYIndexMiddleView.h"

@interface ZYIndexMiddleView()
@property(nonatomic,strong) UIView *bgView;
@property(nonatomic,strong) UILabel *leftLabel;
@property(nonatomic,strong) UILabel *rightLabel;
@end

@implementation ZYIndexMiddleView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

-(void)setup{
    CGFloat left = 15;
    _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width - 30, self.height - 20)];
    _bgView.backgroundColor = RGBA(65, 185, 230, 0.1);
    _bgView.layer.cornerRadius = 5;
    _bgView.layer.masksToBounds = YES;
    [self addSubview:_bgView];
    _bgView.centerX = self.centerX;
    _bgView.centerY = self.centerY;
    
    _leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _bgView.width /2 - left - 5, 25)];
    _leftLabel.textColor = RGBA(102, 102, 102, 1);
    _leftLabel.font = [UIFont systemFontOfSize:20];
    [_bgView addSubview:_leftLabel];
    _leftLabel.left = left;
    _leftLabel.centerY = _bgView.height / 2;
    
    _rightLabel = [[UILabel alloc] initWithFrame:_leftLabel.bounds];
    _rightLabel.textColor = RGBA(153, 153, 153, 1);
    _rightLabel.font = [UIFont systemFontOfSize:12];
    [_bgView addSubview:_rightLabel];
    _rightLabel.left = _bgView.width / 2 + 5;
    _rightLabel.centerY = _bgView.height / 2;
    
    self.backgroundColor = [UIColor whiteColor];
}

-(void)setupTitle{
    _leftLabel.text = [NSString stringWithFormat:@"%@ %.0f",[[ZYChangeLanguage sharedZYChangeLanguage] getStringByKey:LC_INDEX_MAIN_COMPOSITE_INDEX_LABEL],_compositeIndex];
    _rightLabel.text = @"优于94%的站点";
}

-(void)setCompositeIndex:(CGFloat)compositeIndex{
    _compositeIndex = compositeIndex;
    [self setupTitle];
}

@end
